package com.weiyuwqj.server.task;

import com.weiyuwqj.api.model.convert.ModelConvert;
import com.weiyuwqj.api.model.vo.BalanceInfoVo;
import com.weiyuwqj.api.model.vo.FundData;
import com.weiyuwqj.api.service.BusAccountService;
import com.weiyuwqj.api.util.ExcelUtils;
import com.weiyuwqj.api.util.MailUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


import java.util.Arrays;
import java.util.List;

/**
 * Created by huzj on 2016/11/23.
 */
@Component
public class DayAccountCheckTask {
    @Autowired
    private BusAccountService accountService;

//    @Scheduled(cron = "0 10 1 * * ? ")
//    public void checkOrders() {
//        List<FundData> contentList = accountService.checkOrders();
//        if (contentList == null && contentList.size() == 0) {
//            return;
//        }
//        String[] cArray = {"订单号", "金额", "类型"};
//        String[] eArray = {"OrderNo", "Amount", "Type"};
//        ModelConvert[] converts = {null, null, null};
//
//        List<String> cList = Arrays.asList(cArray);
//        List<String> eList = Arrays.asList(eArray);
//        List<ModelConvert> convertList = Arrays.asList(converts);
//
//        String serverDir = this.getClass().getClassLoader().getResource("/").getPath() + "../excel/";
//        String excelFilePath = ExcelUtils.export("对账记录", cList, eList, convertList, contentList, serverDir);
//        MailUtils mailUtils = new MailUtils();
//        mailUtils.attachfile(serverDir + excelFilePath);
//        mailUtils.sendMail();
//    }

//    @Scheduled(cron = "0 20 1 * * ? ")
//    public void checkAccount() {
//        List<BalanceInfoVo> contentList = accountService.checkAccount();
//        if (contentList == null && contentList.size() == 0) {
//            return;
//        }
//        String[] cArray = {"总额", "可用", "冻结", "平台号"};
//        String[] eArray = {"total", "usable", "frozen", "platformId"};
//        ModelConvert[] converts = {null, null, null, null};
//
//        List<String> cList = Arrays.asList(cArray);
//        List<String> eList = Arrays.asList(eArray);
//        List<ModelConvert> convertList = Arrays.asList(converts);
//
//        String serverDir = this.getClass().getClassLoader().getResource("/").getPath() + "../excel/";
//        String excelFilePath = ExcelUtils.export("对账记录", cList, eList, convertList, contentList, serverDir);
//        MailUtils mailUtils = new MailUtils();
//        mailUtils.attachfile(serverDir + excelFilePath);
//        mailUtils.sendMail();
//    }

}
